package com.dkm.repository;

import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.dkm.entity.SignInLog;

public interface SignInLogRepository extends JpaRepository<SignInLog, String>,JpaSpecificationExecutor<SignInLog> {

	/**
	 * 根据用户id和日期获取签到信息
	 * @param user_id
	 * @param date
	 * @return
	 */
	@Query(value = "from SignInLog where user_id=:user_id and sign_in_time between :beigin_time and :end_time")
	SignInLog getSignInLogByUser_idAndDate(@Param("user_id")String user_id,@Param("beigin_time")Date beigin_time,@Param("end_time")Date end_time);
	
	/**
	 * 获取今天所有没有签退的日志
	 * @param beigin_time
	 * @param end_time
	 * @return
	 */
	@Query(value = "from SignInLog where sign_in_time between :beigin_time and :end_time and sign_out_time is null")
	List<SignInLog> getSignInLogByCurDay(@Param("beigin_time")Date beigin_time,@Param("end_time")Date end_time);
}
